home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / PROLOG / BP330 / !BinPro330 / progs / qrev < prev    next >
Text File  |  1994-01-11  |  1KB  |  59 lines

  1. app([],Ys,Ys).
  2. app([A|Xs],Ys,[A|Zs]):-
  3.   app(Xs,Ys,Zs).
  4.  
  5. nrev([],[]).
  6. nrev([X|Xs],R):-
  7.   nrev(Xs,T),
  8.   det_append(T,[X],R). % deterministic append
  9.  
  10. range(Min,Min,Max):-Min=<Max.
  11. range(I,Min,Max):-
  12.         Min<Max,
  13.         Min1 is Min+1,
  14.         range(I,Min1,Max).
  15.  
  16. integers([],I,I):-!.
  17. integers([I0|L],I0,I):-I0<I,I1 is I0+1,integers(L,I1,I).
  18.  
  19. empty_for(It):-range(_,1,It),true,fail.
  20. empty_for(_).
  21.  
  22. full_for(It,L):-range(_,1,It),nrev(L,_),fail.
  23. full_for(_,_).
  24.  
  25. bm(It,Len,Time,Lips):-
  26.     integers(L,0,Len),
  27.     statistics(runtime,_),
  28.     empty_for(It),
  29.     statistics(runtime,[_,T1]),
  30.     full_for(It,L),
  31.     statistics(runtime,[_,T2]),
  32.     TimeMS is T2-T1, Time is TimeMS//10,
  33.     L1 is Len+1,
  34.     L2 is Len+2,
  35.     P is L1*L2,
  36.     LI is P//2,
  37.     Temp is It*LI,
  38.     LIs is 100*Temp,
  39.     Lips is LIs//Time. 
  40.  
  41. htest(N,H,T,S):-
  42.         integers(Is,0,N),
  43.         statistics(global_stack,[H1,_]),
  44.         statistics(trail,[T1,_]),
  45.         statistics(local_stack,[S1,_]),
  46.         nrev(Is,_),
  47.         statistics(global_stack,[H2,_]),
  48.         statistics(trail,[T2,_]),
  49.         statistics(local_stack,[S2,_]),
  50.         H is H2-H1,T is T2-T1,S is S2-S1.
  51.  
  52. rtest(N,[time,T,lips,L,heap,H,trail,Tr,stack,S]):-
  53.     bm(1000,N,T,L),htest(N,H,Tr,S).
  54.  
  55. test(X):-rtest(100,X).
  56.  
  57. go:-test(X),write(X),nl.
  58.  
  59.